#ifndef SERVER_H
#define SERVER_H

#include <stdio.h>
#include "SimpleNetwork/SimpleNetwork.h"

class server {
public:
    server(port) : port(port) {}
    int init();

    static void on_debug(const char * msg) { printf("sock debug:%s\n", msg); }
    static void on_error(const char * msg) { printf("sock debug:%s\n", msg); }
    static void on_message(const char * msg) { printf("sock debug:%s\n", msg); }
    static void on_warning(const char * msg) { printf("sock debug:%s\n", msg); }

    static void on_start(const char * protocol, int port) { printf("sock listen ip:%s portt:%d\n", protocol, port); }
    static void on_shutdown() { printf("sock shutdown\n"); }
    static void on_accept();
    static void on_error(simple::SimpleSession *s) { close(s, "close"); }
    static void on_abort(simple::SimpleSession *s) { close(s, "abort"); }
    static void on_recv(simple::SimpleSession *s, const char*data, int len);
    static void close(simple::SimpleSession *s, const char *prompt);

private:
    short port;
};

#endif // SERVER_H
